import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { JVxeTypes, JVxeColumn } from '/@/components/jeecg/JVxeTable/types'
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '编码',
    align: "center",
    sorter: true,
    dataIndex: 'code'
  },
  {
    title: '名称',
    align: "center",
    sorter: true,
    dataIndex: 'name'
  },
  //  {
  //   title: '时格ID',
  //   align:"center",
  //   dataIndex: 'timeIntervalId'
  //  },
  {
    title: '时格名称',
    align: "center",
    dataIndex: 'timeIntervalName'
  },
  {
    title: '基础算法',
    align: "center",
    dataIndex: 'enabledStatus',
    customRender: ({ text }) => {
      return text == 0 ? '最短工期' : text == 1 ? '最早交货期' : text == 2 ? '按照交期与工期之间的距离' : text == 3 ? 'CR值' : ''
    },
  },
  {
    title: '备注',
    align: "center",
    dataIndex: 'remark'
  },
  {
    title: '第三方编码',
    align: "center",
    dataIndex: 'thirdPartyCode',
    ifShow: false
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "编码",
    field: "code",
    component: 'Input',
    colProps: { span: 6 },
  },
  {
    label: "名称",
    field: "name",
    component: 'Input',
    colProps: { span: 6 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编码',
    field: 'code',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入编码!' },
      ];
    },
  },
  {
    label: '名称',
    field: 'name',
    component: 'Input',
    dynamicRules: () => {
      return [
        { required: true, message: '请输入名称!' },
      ];
    },
  },
  {
    label: '时格ID',
    field: 'timeIntervalId',
    component: 'Input',
    show: false
  },
  {
    label: '排产时格',
    field: 'timeIntervalName',
    component: 'Input',
    slot: 'timeIntervalSlot',
    dynamicRules: () => {
      return [
        { required: true, message: '请选择排产时格!' },
      ];
    },
  },
  {
    label: '基础算法',
    field: 'enabledStatus',
    component: 'Select',
    defaultValue: 0,
    componentProps: {
      options: [{ label: '最短工期', value: 0 }, { label: '最早交货期', value: 1 }, { label: '按照交期与工期之间的距离', value: 2 }, { label: 'CR值', value: 3 }],
      stringToNumber: true,
    }
  },

  {
    label: '第三方编码',
    field: 'thirdPartyCode',
    component: 'Input',
    ifShow: false
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];
//子表单数据
//子表表格配置
export const basProductSchedulePlanItemColumns: JVxeColumn[] = [
  {
    title: '排产方案ID',
    key: 'productSchedulePlanId',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '规则名称',
    key: 'ruleName',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '排序规则',
    key: 'collationRule',
    type: JVxeTypes.select,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: 0,
    options: [{ label: '升序', value: 0 }, { label: '降序', value: 1 }]
  },
  {
    title: '优先顺序',
    key: 'priority',
    type: JVxeTypes.inputNumber,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '是否启用',
    key: 'enabledStatus',
    type: JVxeTypes.select,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: 1,
    options: [{ label: '否', value: 0 }, { label: '是', value: 1 }]
  },
  {
    title: '备注',
    key: 'remark',
    type: JVxeTypes.input,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
  {
    title: '第三方编码',
    key: 'thirdPartyCode',
    type: JVxeTypes.hidden,
    width: "200px",
    placeholder: '请输入${title}',
    defaultValue: '',
  },
]


/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}